package com.geyue.controller;

import com.geyue.common.toolbox.result.Res;
import com.geyue.core.model.Teacher;
import com.geyue.core.service.BannerService;
import com.geyue.core.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Chen on 2017/4/20.
 */
@RestController
@RequestMapping("/api/index")
public class IndexController {

    @Autowired
    private BannerService bannerService;

    @Autowired
    private TeacherService teacherService;


    /**
     * 跳转登录
     * @return
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index() {
        return "login";
    }

    /**
     * 跳转登录
     * @return
     */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login() {
        return "login";
    }

    /**
     * 获取幻灯片
     * @return
     */
    @RequestMapping(value = "/allBanner",method = RequestMethod.GET)
    @ResponseBody
    public Object allBanner(){

        return bannerService.getList();
    }

    /**
     * 首页获取推荐的老师
     * @return
     */
    @RequestMapping(value = "/getTeacherByTop",method = RequestMethod.GET)
    @ResponseBody
    public Object getTeacherByTop(){

        return teacherService.getTopList();
    }

    /**
     * 首页查询
     * @param keyword
     * @return
     */
    @RequestMapping(value = "/searchTeacher",method = RequestMethod.GET)
    @ResponseBody
    public Object searchTeacher(String keyword){

        return teacherService.searchTeacher(keyword);
    }



}
